<%@ page language="java" pageEncoding="UTF-8"%>
<!doctype html>
<html lang="zh-CN">
<head>
<%@include file="/WEB-INF/views/commons/common.jsp"%>
<link rel="stylesheet" type="text/css" href="${base_href}/static/ui-frame/bootstrap/3.3.5/css/bootstrap.min.css">
<link rel="stylesheet" type="text/css" href="${base_href}/static/ui-frame/bootstrap-dialog3/css/bootstrap-dialog.css">
<link rel="stylesheet" type="text/css" href="${base_href}/static/ui-frame/validation-engine/validationEngine.jquery.css">
<link rel="stylesheet" type="text/css" href="${base_href}/static/ui-frame/jquery-easyui/1.4.3/themes/metro/easyui.css">
<link rel="stylesheet" type="text/css" href="${base_href}/static/ui-frame/font-awesome/4.3.0/css/font-awesome.min.css">

<link rel="stylesheet" type="text/css" href="${base_href}/static/ui-frame/webuploader/0.1.5/webuploader.css">
<link rel="stylesheet" type="text/css" href="${base_href}/static/ui-frame/viewer/viewer.css">

<link rel="stylesheet" type="text/css" href="${base_href}/static/css/search-theme.css">
<link rel="stylesheet" type="text/css" href="${base_href}/static/css/form-theme.css">

<title>题目详细信息</title>
</head>
<body data-spy="scroll" data-target="#myScrollspy" data-offset="350">


	<div class="main-wrap">
		<!-- 工具条 start-->
		<div class="container-fluid form-body-header">
			<div class="container">
				<div class="row tool-bar">
					<div class="col-xs-12">
						<button type="button" class="btn btn-sm tool-btn" id="copyBtn">一键复制</button>
					</div>
				</div>
			</div>
		</div>
		<!-- 工具条 end-->

		<!-- 表单 start-->
		<div class="container-fluid">
			<form id="form">
			
				<input type="hidden" name="quesId" value="${form.quesId }" />
				<input type="hidden" name="replyId" value="${form.replyId }" />
				<input type="hidden" name="quesType" value="${form.quesType }" />
				<div class="container form-body-div">
					<div class="row text-center title-body" id="baseinfo">
						问题详细信息<br />
					</div>
					<div class="row pannel-title">
						<span>基本信息</span> <a href="javascript:void(0);" class="hide-next-btn">收起</a>
					</div>
					<div class="row pannel-body">
						<table class="form-table">
							<tr>
								<th class="col-xs-2 " rowspan="6">问题</th>
								
								<th class="col-xs-2 ">问题来源</th>
								<td class="col-xs-2">
									<c:forEach items="${questionSources}" var="dic">
										<c:if test="${dic.code eq form.questionSource}">${dic.value}</c:if>
									</c:forEach> 
								</td>
								<th class="col-xs-2 ">是否追问</th>
								<td class="col-xs-4" >
									<c:if test="${'0' eq form.quesClosely}">否</c:if>
									<c:if test="${'1' eq form.quesClosely}">是</c:if>
								</td>
							</tr>
							<tr>
								<th class="col-xs-2">学生信息</th>
								<td class="col-xs-10" colspan="3">
									${form.quesUserName}
								</td>
							</tr>
							<tr>
								<th class="col-xs-2 ">考试类别</th>
								<td class="col-xs-2">
									<c:forEach items="${quesBookClasses}" var="dic">
										<c:if test="${dic.code eq form.bookClass}">${dic.value}</c:if>
									</c:forEach> 
								</td>
								<th class="col-xs-2 ">图书名称</th>
								<td class="col-xs-4">
									<c:if test="${form.bookClass eq '1'}">
										<c:forEach items="${quesBookClasses1}" var="dic">
											<c:if test="${dic.code eq form.bookSecClass}">${dic.value}</c:if>
										</c:forEach> 
									</c:if>
									<c:if test="${form.bookClass eq '2'}">
										<c:forEach items="${quesBookClasses2}" var="dic">
											<c:if test="${dic.code eq form.bookSecClass}">${dic.value}</c:if>
										</c:forEach> 
									</c:if>
									<c:if test="${form.bookClass eq '3'}">
										<c:forEach items="${quesBookClasses3}" var="dic">
											<c:if test="${dic.code eq form.bookSecClass}">${dic.value}</c:if>
										</c:forEach> 
									</c:if>
									<c:if test="${form.bookClass eq '4'}">
										<c:forEach items="${quesBookClasses4}" var="dic">
											<c:if test="${dic.code eq form.bookSecClass}">${dic.value}</c:if>
										</c:forEach> 
									</c:if>
								</td>
							</tr>
							<tr>
								<th class="col-xs-2 ">图书页码</th>
								<td class="col-xs-2">
									${form.pageNum}
								</td>
								<th class="col-xs-2 ">用户等级</th>
								<td class="col-xs-4">
									<c:forEach items="${userTypes}" var="dic">
										<c:if test="${dic.code eq form.userType}">${dic.value}</c:if>
									</c:forEach> 
								</td>
							</tr>
							<tr>
								<th class="col-xs-2 ">问题详情</th>
								<td class="col-xs-10" colspan="3">
									<textarea class="form-control " rows="10" name="quesDescribe" 
										readonly="readonly">${form.quesDescribe}</textarea>
								</td>
							</tr>
							<tr>
								<th class="col-xs-2 ">问题图片</th>
								<td class="col-xs-10" colspan="3">
									<c:forEach items="${form.quesPics}" var="pic">
										<img alt="" src="${pic}">
									</c:forEach>
									<table data-ms-class="attachment"
										class="attach-no-table upload-download-element" data-show-upload-button=false
										data-title="上传附件" data-is-readonly=true data-box-id="${form.quesId }"
										>
									</table>
								</td>
							</tr>
							<tr>
								<td colspan="4">
									<span style="float:right">
									<fmt:formatDate value="${form.quesTime}" type="both" pattern="yyyy-MM-dd HH:mm" />
									</span>
								</td>
							</tr>
							<tr>
								<th class="col-xs-2 ">问题难度</th>
								<td colspan="2">
									<c:forEach items="${quesDiffLevels}" var="state">
										<c:if test="${state.code eq form.quesDiffLevel}">${state.value}</c:if>
									</c:forEach> 
								</td>
								<th class="col-xs-2 ">认领教师</th>
								<td class="col-xs-4">
									${form.claimUserName}
								</td>
							</tr>
							
							<tr>
								<th class="col-xs-2 " rowspan="3">回复</th>
								<td class="col-xs-10" colspan="4">
									<div id="myAnwser" class="pre-div">${form.myAnwser}</div>
								</td>
							</tr>
							
							<tr>
								<td class="text-right col-xs-10" colspan="4">
									<div>
										<table data-ms-class="attachment"
											class="attach-no-table upload-download-element" data-show-upload-button=false
											data-title="上传附件" data-is-readonly=true data-box-id="${form.replyId }"
											>
										</table>
									</div>
								</td>
							</tr>
							<tr>
								<td colspan="4">
									<span style="float:right">
									<fmt:formatDate value="${form.replyTime}" type="both" pattern="yyyy-MM-dd HH:mm" />
									</span>
								</td>
							</tr>
							<tr>
								<td class="text-right col-xs-10" colspan="5">
									<button class="btn" data-clipboard-action="copy" data-clipboard-target="#myAnwser"><i class="fa fa-copy"></i>&nbsp;复制答案&nbsp;</button>
								</td>
							</tr>
						</table>
					</div>
				</div>
			</form>
		</div>
		<!-- 表单 end-->
		
	</div>
	<script type="text/javascript" src="${base_href}/static/ui-frame/jquery/1.11.3/jquery.js"></script>
	<script type="text/javascript" src="${base_href}/static/ui-frame/bootstrap/3.3.5/js/bootstrap.js"></script>
	<script type="text/javascript" src="${base_href}/static/ui-frame/bootstrap-dialog3/js/bootstrap-dialog.js"></script>
	<script type="text/javascript" src="${base_href}/static/ui-frame/validation-engine/jquery.validationEngine-zh_CN.js"></script>
	<script type="text/javascript" src="${base_href}/static/ui-frame/validation-engine/jquery.validationEngine.js"></script>
	<script type="text/javascript" src="${base_href}/static/ui-frame/My97DatePicker/WdatePicker.js"></script>
	
	<script type="text/javascript" src="${base_href}/static/ui-frame/jquery-easyui/1.4.3/jquery.easyui.min.js"></script>
	<script type="text/javascript" src="${base_href}/static/ui-frame/jquery-easyui/1.4.3/easyui.util.js"></script>
	
	<script type="text/javascript" src="${base_href}/static/ui-frame/webuploader/0.1.5/mbs-upload.js"></script>
	<script type="text/javascript" src="${base_href}/static/ui-frame/viewer/viewer.js"></script>
	<script type="text/javascript" src="${base_href}/static/ui-frame/clipboard/clipboard.min.js"></script>
	<script type="text/javascript" src="${base_href}/static/ui-frame/layer/layer.js"></script>
	
</body>
<script type="text/javascript">
	$(function() {
		new Clipboard('.btn');
		
		$("#copyBtn").click(function(){
			var quesType = $("input[name='quesType']").val();
			if(quesType < 4){
				layer.alert("该题目尚未解决，无法复制到数据中心。")
			}else{
				copyQues();
			}
			
		})
	});
	$(document).on('click', 'img', function(){
		$(this).viewer();
	});
	
	function copyQues(){
		var html = 
			'<table class="form-table">'+
				'<tr>'+
					'<th class="col-xs-2">所属专业</th>'+
					'<td class="col-xs-4">'+
						'<select name="major" class="form-control validate[required]">'+
							'<option value="">请选择</option>'+
						'</select>'+
					'</td>'+
					'<th class="col-xs-2">所属科目</th>'+
					'<td class="col-xs-4">'+
						'<select name="subject" class="form-control validate[required]">'+
							'<option value="">请选择</option>'+
						'</select>'+
					'</td>'+
				'</tr>'+
				'<tr>'+
					'<th class="col-xs-2">关联题目题干</th>'+
					'<td class="col-xs-10" colspan="3">'+
						'<textarea class="form-control validate[maxSize[250]]" '+
							'data-errormessage-range-overflow="关联题目题干不能超过250个字" rows="5" '+
							'name="relatedQuestion" ></textarea>'+
					'</td>'+
				'</tr>'+
			'</table>';
		layer.open({
			btn: ['确定', '取消'],
			type: 1,
			title: '一键复制题目补充信息',
			shadeClose: true,
			shade: 0.8,
			area: '541px',
			content: html,
			success: function(layero, index){
				$.ajax({
					url: basePath + "/dictionary/getDicsByModel.json?model=clean_major_type",
					type: "get",
					dataType:"json",
					success: function(r){
						var $majorSel = $("select[name=major]");
						for(var i=0; i<r.length; i++){
							var optionHtml = "<option value='"+r[i].code+"'>"+r[i].value+"</option>";
							$majorSel.append(optionHtml);
						}
					}
				});
				$.ajax({
					url: basePath + "/dictionary/getDicsByModel.json?model=clean_subject_type",
					type: "get",
					dataType:"json",
					success: function(r){
						var $subjectSel = $("select[name=subject]");
						for(var i=0; i<r.length; i++){
							var optionHtml = "<option value='"+r[i].code+"'>"+r[i].value+"</option>";
							$subjectSel.append(optionHtml);
						}
					}
				});
			},
			btn1: function(index, layero){
				var major = $("select[name=major]").val();
				var subject = $("select[name=subject]").val();
				if(major == "" || subject == ""){
					layer.open({ title: '提示' ,content: '请选择专业和科目' });
				}else{
					var quesId = $("input[name='quesId']").val();
					var relatedQues = $("textarea[name='relatedQuestion']").val();
					var url = basePath + "/replication/copy.json";
					$.ajax({
						url:  url,
						data: {"quesId":quesId,"major":major,"subject":subject,"relatedQues":relatedQues},
						type: "post",
						dataType:"json",
						success: function(r){
							if(r.code == 2000){
								layer.msg("拷贝成功");
								layer.close(index);
							}else{
								layer.alert(r.message);
							}
						}
					})
					.fail(function() { layer.alert("拷贝问题失败，请联系管理员");})
				}
				
			},
			btn2: function(index, layero){
			  //return false 开启该代码可禁止点击该按钮关闭
			}
		})
	}
</script>
</html>
